MIUI security components.apk(点击下载) / a.java


package tmsdk.common.module.update;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.qq.taf.jce.JceStruct;
import com.xiaomi.onetrack.OneTrack;
import java.io.File;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import tmsdk.bg.tcc.TelNumberLocator;
import tmsdk.common.NumMarker;
import tmsdk.common.YellowPages;
import tmsdk.common.creator.BaseManagerC;
import tmsdk.common.creator.ManagerCreatorC;
import tmsdk.common.module.qscanner.impl.AmScannerV2;
import tmsdk.common.roach.nest.PowerNest;
import tmsdkobf.a0;
import tmsdkobf.b5;
import tmsdkobf.c0;
import tmsdkobf.cc;
import tmsdkobf.e0;
import tmsdkobf.ea;
import tmsdkobf.f0;
import tmsdkobf.f3;
import tmsdkobf.f5;
import tmsdkobf.g2;
import tmsdkobf.ha;
import tmsdkobf.ia;
import tmsdkobf.ja;
import tmsdkobf.l;
import tmsdkobf.m2;
import tmsdkobf.n6;
import tmsdkobf.o2;
import tmsdkobf.p2;
import tmsdkobf.ra;
import tmsdkobf.sb;
import tmsdkobf.v3;
import tmsdkobf.x1;
import tmsdkobf.x5;
import tmsdkobf.y9;

/* access modifiers changed from: package-private */
public final class a extends BaseManagerC {

    /* renamed from: b  reason: collision with root package name */
    private Context f977b;
    private String c = null;
    private AtomicBoolean d = new AtomicBoolean(false);
    private HashMap<Long, SoftReference<IUpdateObserver>> e = new HashMap<>();
    private b f;

    /* access modifiers changed from: package-private */
    /* renamed from: tmsdk.common.module.update.a$a  reason: collision with other inner class name */
    public class C0040a implements v3 {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ long f978a;

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ ICheckListener f979b;
        final /* synthetic */ ArrayList c;

        C0040a(long j, ICheckListener iCheckListener, ArrayList arrayList) {
            this.f978a = j;
            this.f979b = iCheckListener;
            this.c = arrayList;
        }

        @Override // tmsdkobf.v3
        public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) {
            ArrayList<f0> arrayList;
            int i5;
            ICheckListener iCheckListener;
            a aVar;
            String str;
            StringBuilder sb;
            String str2;
            int i6;
            sb.a("UpdateMgr", (Object) ("[Shark]onFinish-Cmd_CSConfInfo, elapsed time:[" + (System.currentTimeMillis() - this.f978a) + "]cmdId:[" + i2 + "]retCode:[" + i3 + "]dataRetCode: " + i4));
            sb.b("UpdateMgr", "[UpdateManager] disconnect for check update data");
            if (jceStruct == null) {
                sb.e("UpdateMgr", "null == resp");
                a.this.a((a) -205, (int) this.f979b);
                return;
            }
            e0 e0Var = (e0) jceStruct;
            if (e0Var == null || (arrayList = e0Var.f) == null) {
                sb.e("UpdateMgr", "(SCConfInfo)resp.vecConfInfo empty");
                a.this.a((a) -205, (int) this.f979b);
            } else if (arrayList.size() <= 0) {
                sb.a("UpdateMgr", (Object) "size: 0, no available db");
                a.this.a((a) i3, (int) this.f979b);
            } else if (i3 == 0) {
                Iterator<f0> it = e0Var.f.iterator();
                int i7 = 0;
                while (it.hasNext()) {
                    f0 next = it.next();
                    if (next != null) {
                        StringBuilder sb2 = new StringBuilder();
                        sb2.append("[");
                        int i8 = i7 + 1;
                        sb2.append(i7);
                        sb2.append("]resp::fileId:[");
                        sb2.append(next.f1068b);
                        sb2.append("]isIncreUpdate:[");
                        sb2.append(next.f);
                        sb2.append("]");
                        sb.a("UpdateMgr", (Object) sb2.toString());
                        UpdateInfo updateInfo = new UpdateInfo();
                        if (40458 == next.f1068b || UpdateConfig.getLargeMarkFileId() == (i6 = next.f1068b) || 40801 == i6 || 40800 == i6 || 40461 == i6) {
                            str2 = ".sdb";
                            if (next.f) {
                                sb = new StringBuilder();
                                sb.append(UpdateConfig.intToString(next.f1068b));
                            } else {
                                sb = new StringBuilder();
                                sb.append(UpdateConfig.intToString(next.f1068b));
                                sb.append(str2);
                                str = sb.toString();
                                updateInfo.fileName = str;
                                updateInfo.mFileID = next.f1068b;
                                sb.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]"));
                                updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1068b);
                                updateInfo.type = 0;
                                updateInfo.url = next.e;
                                updateInfo.data1 = next;
                                updateInfo.fileSize = next.j;
                                this.c.add(updateInfo);
                                i7 = i8;
                            }
                        } else if (next.f) {
                            sb = new StringBuilder();
                            str2 = UpdateConfig.getFileNameByFileId(next.f1068b);
                        } else {
                            str = UpdateConfig.getFileNameByFileId(i6);
                            updateInfo.fileName = str;
                            updateInfo.mFileID = next.f1068b;
                            sb.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]"));
                            updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1068b);
                            updateInfo.type = 0;
                            updateInfo.url = next.e;
                            updateInfo.data1 = next;
                            updateInfo.fileSize = next.j;
                            this.c.add(updateInfo);
                            i7 = i8;
                        }
                        sb.append(str2);
                        sb.append(UpdateConfig.PATCH_SUFIX);
                        str = sb.toString();
                        updateInfo.fileName = str;
                        updateInfo.mFileID = next.f1068b;
                        sb.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]"));
                        updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1068b);
                        updateInfo.type = 0;
                        updateInfo.url = next.e;
                        updateInfo.data1 = next;
                        updateInfo.fileSize = next.j;
                        this.c.add(updateInfo);
                        i7 = i8;
                    }
                }
                CheckResult checkResult = new CheckResult();
                l lVar = e0Var.d;
                String str3 = "";
                checkResult.mTitle = lVar != null ? lVar.f1182b : str3;
                if (lVar != null) {
                    str3 = lVar.c;
                }
                checkResult.mMessage = str3;
                checkResult.mUpdateInfoList = this.c;
                if (this.f979b != null) {
                    sb.a("UpdateMgr", (Object) "[callback]onCheckFinished");
                    this.f979b.onCheckFinished(checkResult);
                }
                sb.a("UpdateMgr", (Object) ("title:[" + checkResult.mTitle + "]msg:[" + checkResult.mMessage + "]"));
            } else {
                sb.a("UpdateMgr", (Object) ("failed, retCode: " + i3));
                if (i3 % 20 == -4) {
                    aVar = a.this;
                    iCheckListener = this.f979b;
                    i5 = -206;
                } else {
                    aVar = a.this;
                    iCheckListener = this.f979b;
                    i5 = -999;
                }
                aVar.a((a) i5, (int) iCheckListener);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements ia.a {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ IUpdateListener f980a;

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ UpdateInfo f981b;
        final /* synthetic */ AtomicBoolean c;

        b(a aVar, IUpdateListener iUpdateListener, UpdateInfo updateInfo, AtomicBoolean atomicBoolean) {
            this.f980a = iUpdateListener;
            this.f981b = updateInfo;
            this.c = atomicBoolean;
        }

        @Override // tmsdkobf.ia.a
        public void a(Bundle bundle) {
        }

        @Override // tmsdkobf.ia.a
        public void b(Bundle bundle) {
            int i = bundle.getInt("key_errcode");
            if (this.f980a != null) {
                sb.a("UpdateMgr", (Object) ("[callback]onUpdateEvent:[" + i + "]"));
                this.f980a.onUpdateEvent(this.f981b, i);
            }
            this.c.set(true);
            UpdateInfo updateInfo = this.f981b;
            updateInfo.errorCode = i;
            updateInfo.errorMsg = bundle.getString("key_errorMsg");
            this.f981b.downSize = bundle.getInt("key_downSize");
            this.f981b.fileSize = bundle.getInt("key_total");
            this.f981b.sdcardStatus = bundle.getInt("key_sdcardstatus");
            this.f981b.downType = bundle.getByte("key_downType");
        }
    }

    /* access modifiers changed from: package-private */
    public class c implements ja.a {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ UpdateInfo f982a;

        c(UpdateInfo updateInfo) {
            this.f982a = updateInfo;
        }

        @Override // tmsdkobf.ja.a
        public boolean a(String str) {
            f0 f0Var = (f0) this.f982a.data1;
            if (f0Var == null) {
                return true;
            }
            StringBuilder sb = new StringBuilder();
            sb.append("isMatch confSrc.md5Bin = ");
            byte[] bArr = f0Var.c;
            sb.append(bArr == null ? "null" : Arrays.toString(bArr));
            Log.e("UpdateMgr", sb.toString());
            String c = ea.c(f0Var.c);
            int i = f0Var.m;
            if (i == 2) {
                File parentFile = new File(str).getParentFile();
                String str2 = parentFile.getPath() + File.separator + "tempZip" + File.separator;
                try {
                    File file = new File(str2);
                    if (file.exists()) {
                        n6.a(file);
                    }
                    f3.a(str, str2);
                    File[] listFiles = file.listFiles();
                    if (listFiles != null) {
                        if (listFiles.length != 0) {
                            if (listFiles.length != 1) {
                                return false;
                            }
                            if (str.length() > 8) {
                                str = str.substring(0, str.length() - 8);
                            } else {
                                str = str + ".tmp";
                            }
                            File file2 = new File(str);
                            if (file2.exists()) {
                                file2.delete();
                            }
                            n6.a(listFiles[0], file2);
                            n6.a(file);
                        }
                    }
                    return false;
                } catch (Exception e) {
                    sb.a("UpdateMgr", "unzip num mark file failed", e);
                    return false;
                }
            } else if (i == 1) {
                sb.b("UpdateMgr", (Object) "num mark file should not zip encrypt");
                return false;
            } else {
                sb.c("UpdateMgr", (Object) "normal num mark file");
            }
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            boolean a2 = a.this.a((a) str, c);
            sb.c(NumMarker.Tag, (Object) ("DataMd5Cheker isMatch() isMth: " + a2));
            return a2;
        }
    }

    /* access modifiers changed from: package-private */
    public class d implements ja.a {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ UpdateInfo f984a;

        d(UpdateInfo updateInfo) {
            this.f984a = updateInfo;
        }

        @Override // tmsdkobf.ja.a
        public boolean a(String str) {
            sb.c("UpdateMgr", (Object) ("isMatch filePath = " + str));
            f0 f0Var = (f0) this.f984a.data1;
            if (f0Var == null) {
                return true;
            }
            StringBuilder sb = new StringBuilder();
            sb.append("isMatch confSrc.md5Bin = ");
            byte[] bArr = f0Var.c;
            sb.append(bArr == null ? "null" : Arrays.toString(bArr));
            sb.c("UpdateMgr", (Object) sb.toString());
            return a.this.b(str, ea.c(f0Var.c));
        }
    }

    /* access modifiers changed from: package-private */
    public class e implements v3 {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ long f986a;

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ AtomicReference f987b;
        final /* synthetic */ Object c;

        e(long j, AtomicReference atomicReference, Object obj) {
            this.f986a = j;
            this.f987b = atomicReference;
            this.c = obj;
        }

        @Override // tmsdkobf.v3
        public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) {
            int i5;
            AtomicReference atomicReference;
            String str;
            String str2;
            sb.a("UpdateMgr", (Object) ("[Shark]onFinish-Cmd_CSUpdateVirusInfos, elapsed time:[" + (System.currentTimeMillis() - this.f986a) + "]cmdId:[" + i2 + "]retCode:[" + i3 + "]dataRetCode: " + i4));
            sb.b("UpdateMgr", "[UpdateManager] disconnect for updateVirus");
            StringBuilder sb = new StringBuilder();
            sb.append(i3);
            sb.append(";");
            sb.append(i4);
            y9.c(1320094, sb.toString());
            if (i3 == 0 && i4 == 0) {
                if (jceStruct != null) {
                    g2 g2Var = (g2) jceStruct;
                    p2 p2Var = g2Var.f1090b;
                    ArrayList<o2> arrayList = g2Var.c;
                    if (p2Var == null) {
                        str2 = "UpdateMgr";
                        str = "SCUpdateVirusInfos.serverinfo is null!";
                    } else if (p2Var.a()) {
                        sb.e("UpdateMgr", "need update engine, donnot update virus base!");
                    } else if (arrayList == null || arrayList.size() <= 0) {
                        sb.e("UpdateMgr", "no update info, virusInfoList: " + arrayList);
                    } else {
                        String b2 = cc.b(a.this.f977b, (long) UpdateConfig.UPDATE_FLAG_VIRUS_BASE);
                        int a2 = AmScannerV2.a(a.this.f977b, b2, p2Var, arrayList);
                        this.f987b.set(Integer.valueOf(a2));
                        if (a2 != 0) {
                            sb.e("UpdateMgr", "amf file error, delete:[" + b2 + "]");
                            ha.a(b2);
                        }
                        sb.a("UpdateMgr", (Object) ("native updateBase, size: " + arrayList.size() + " ret: " + a2));
                    }
                } else {
                    str2 = "UpdateMgr";
                    str = "SCUpdateVirusInfos is null!";
                }
                sb.e(str2, str);
                this.f987b.set(-6);
            } else {
                sb.e("UpdateMgr", "retCode != 0 || dataRetCode != 0");
                if (i3 % 20 == -4) {
                    atomicReference = this.f987b;
                    i5 = -206;
                } else {
                    atomicReference = this.f987b;
                    i5 = -999;
                }
                atomicReference.set(Integer.valueOf(i5));
                if (i4 != 0) {
                    this.f987b.set(-205);
                }
            }
            synchronized (this.c) {
                this.c.notify();
            }
        }
    }

    a() {
    }

    private List<c0> a(long j) {
        c0 a2;
        ArrayList arrayList = new ArrayList();
        if (j == UpdateConfig.UPDATA_FLAG_NUM_MARK) {
            arrayList.add(a(40458));
            a2 = a(UpdateConfig.getLargeMarkFileId());
        } else if (j == 2) {
            a2 = cc.a(50001, cc.a(this.f977b, 50001, ".sdb"));
        } else if (j == UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large) {
            a2 = cc.c(40461, cc.a(this.f977b, 40461, ".sdb"));
            if (a2 != null) {
                sb.c("gjj", (Object) ("fileId:" + a2.f1028b + " timestamp:" + a2.d + " pfutimestamp:" + a2.e + " version:" + a2.g));
            }
            return arrayList;
        } else {
            a2 = cc.a(this.f977b, j);
        }
        arrayList.add(a2);
        return arrayList;
    }

    private c0 a(int i) {
        c0 b2 = cc.b(i, cc.a(this.f977b, i, ".sdb"));
        if (b2 == null) {
            b2 = new c0();
            b2.f1028b = i;
            b2.c = new byte[0];
            b2.d = 0;
        }
        if (b2.c == null) {
            b2.c = ea.a("");
        }
        sb.c(NumMarker.Tag, (Object) ("fileId:" + b2.f1028b + " timestamp:" + b2.d + " pfutimestamp:" + b2.e + " version:" + b2.g));
        return b2;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(int i, ICheckListener iCheckListener) {
        if (iCheckListener != null) {
            if (i != 0) {
                sb.a("UpdateMgr", (Object) ("[callback]onCheckEvent:[" + i + "]"));
                iCheckListener.onCheckEvent(i);
            }
            sb.a("UpdateMgr", (Object) "[callback]onCheckFinished--null");
            iCheckListener.onCheckFinished(null);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean a(String str, String str2) {
        String a2 = ((ra) ManagerCreatorC.getManager(ra.class)).a(str);
        return (str2 == null || a2 == null || !str2.toLowerCase().equals(a2.toLowerCase())) ? false : true;
    }

    private boolean a(c0 c0Var, String str) {
        String str2;
        if (c0Var == null) {
            str2 = "isMd5Match() confInfoFromFile is null";
        } else {
            byte[] bArr = c0Var.c;
            if (bArr == null || bArr.length == 0) {
                str2 = "isMd5Match() confInfoFromFile.md5Bin is empty";
            } else {
                String a2 = ea.a(bArr);
                if (str == null || a2 == null) {
                    str2 = "isMd5Match() md5FromUpdateInfo or md5FromFileHeader is null";
                } else {
                    sb.c("UpdateMgr", (Object) ("isMd5Match() md5FromUpdateInfo:" + str.toLowerCase() + " md5FromFileHeader:" + a2.toLowerCase()));
                    if (!str.toLowerCase().equals(a2.toLowerCase())) {
                        str2 = "isMd5Match() md5FromUpdateInfo and md5FromFileHeader is not match";
                    } else {
                        sb.c("UpdateMgr", (Object) "isMd5Match() = true");
                        return true;
                    }
                }
            }
        }
        sb.c("UpdateMgr", (Object) str2);
        return false;
    }

    private int b(int i) {
        AtomicReference atomicReference = new AtomicReference(0);
        Context context = this.f977b;
        m2 c2 = cc.c(context, cc.b(context, (long) UpdateConfig.UPDATE_FLAG_VIRUS_BASE));
        if (c2 != null) {
            c2.d = 3;
            c2.e = i;
            x1 x1Var = new x1();
            x1Var.f1410b = c2;
            long currentTimeMillis = System.currentTimeMillis();
            Object obj = new Object();
            x5 f2 = b5.f();
            sb.a("UpdateMgr", (Object) ("[Shark]Cmd_CSUpdateVirusInfos, sendShark, guid:[" + f2.b() + "]"));
            f2.a(2006, x1Var, new g2(), PowerNest.SHARK_HTTP, new e(currentTimeMillis, atomicReference, obj), 180000);
            synchronized (obj) {
                try {
                    obj.wait();
                } catch (Exception e2) {
                    sb.c("UpdateMgr", "SCAN_LOCK.wait(): " + e2, e2);
                }
            }
        } else {
            sb.e("UpdateMgr", "getVirusClientInfo return null!");
            atomicReference.set(-2);
        }
        return ((Integer) atomicReference.get()).intValue();
    }

    @Deprecated
    private c0 b(long j) {
        if (j != 4) {
            if (j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE || j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) {
                Context context = this.f977b;
                return cc.b(context, cc.b(context, j));
            } else if (j == 2) {
                return cc.a(50001, cc.b(this.f977b, j));
            } else {
                if (j != 2147483648L) {
                    return cc.a(this.f977b, j);
                }
            }
        }
        return null;
    }

    private void b(UpdateInfo updateInfo) {
        TelNumberLocator telNumberLocator = TelNumberLocator.getDefault(this.f977b);
        f0 f0Var = (f0) updateInfo.data1;
        if (f0Var.f) {
            telNumberLocator.patchLocation(this.c + File.separator + updateInfo.fileName, ea.a(f0Var.c));
        }
        telNumberLocator.reload();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private boolean b(String str, String str2) {
        sb.c("UpdateMgr", (Object) ("isYellowPageMd5Match() filePath:" + str + " md5FromUpdateInfo:" + str2));
        return a(cc.c(40461, str), str2);
    }

    private void c(UpdateInfo updateInfo) {
        String str = this.c + File.separator + updateInfo.fileName;
        f0 f0Var = (f0) updateInfo.data1;
        if (f0Var != null) {
            int i = f0Var.m;
            if (i == 2) {
                String str2 = this.c + File.separator + "zipTemp" + File.separator;
                try {
                    File file = new File(str2);
                    if (file.exists()) {
                        n6.a(file);
                    }
                    f3.a(str, str2);
                    File[] listFiles = file.listFiles();
                    if (listFiles == null) {
                        return;
                    }
                    if (listFiles.length != 0) {
                        if (listFiles.length == 1) {
                            File file2 = new File(str);
                            if (file2.exists()) {
                                file2.delete();
                            }
                            n6.a(listFiles[0], file2);
                            n6.a(file);
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                } catch (Exception e2) {
                    sb.a("UpdateMgr", "unzip num mark big file failed", e2);
                    return;
                }
            } else if (i == 1) {
                sb.b("UpdateMgr", (Object) "num mark big file should not zip encrypt");
                return;
            } else {
                sb.c("UpdateMgr", (Object) "normal num mark big file");
            }
            String c2 = !f0Var.f ? ea.c(f0Var.c) : ea.c(f0Var.g);
            ra raVar = (ra) ManagerCreatorC.getManager(ra.class);
            if (raVar == null) {
                return;
            }
            if (raVar.a(str, c2) == 0) {
                raVar.e();
            } else {
                raVar.c();
            }
        }
    }

    private void d(UpdateInfo updateInfo) {
        String str = this.c + File.separator + updateInfo.fileName;
        f0 f0Var = (f0) updateInfo.data1;
        if (f0Var != null) {
            int i = f0Var.m;
            if (i == 2) {
                String str2 = this.c + File.separator + "zipTemp" + File.separator;
                try {
                    File file = new File(str2);
                    if (file.exists()) {
                        n6.a(file);
                    }
                    f3.a(str, str2);
                    File[] listFiles = file.listFiles();
                    if (listFiles == null) {
                        return;
                    }
                    if (listFiles.length != 0) {
                        if (listFiles.length == 1) {
                            File file2 = new File(str);
                            if (file2.exists()) {
                                file2.delete();
                            }
                            n6.a(listFiles[0], file2);
                            n6.a(file);
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                } catch (Exception e2) {
                    sb.a("UpdateMgr", "unzip num mark file failed", e2);
                    return;
                }
            } else if (i == 1) {
                sb.b("UpdateMgr", (Object) "num mark file should not zip encrypt");
                return;
            } else {
                sb.c("UpdateMgr", (Object) "normal num mark file");
            }
            String c2 = !f0Var.f ? ea.c(f0Var.c) : ea.c(f0Var.g);
            ra raVar = (ra) ManagerCreatorC.getManager(ra.class);
            if (raVar == null) {
                return;
            }
            if (raVar.b(str, c2) == 0) {
                raVar.e();
            } else {
                raVar.c();
            }
        }
    }

    private void e(UpdateInfo updateInfo) {
        String str = this.c + File.separator + updateInfo.fileName;
        f0 f0Var = (f0) updateInfo.data1;
        if (f0Var != null) {
            int i = f0Var.m;
            if (i == 2) {
                String str2 = this.c + File.separator + "zipTemp" + File.separator;
                try {
                    File file = new File(str2);
                    if (file.exists()) {
                        n6.a(file);
                    }
                    f3.a(str, str2);
                    File[] listFiles = file.listFiles();
                    if (listFiles == null) {
                        return;
                    }
                    if (listFiles.length != 0) {
                        if (listFiles.length == 1) {
                            File file2 = new File(str);
                            if (file2.exists()) {
                                file2.delete();
                            }
                            n6.a(listFiles[0], file2);
                            n6.a(file);
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                } catch (Exception e2) {
                    sb.a("UpdateMgr", "unzip num mark big file failed", e2);
                    return;
                }
            } else if (i == 1) {
                sb.b("UpdateMgr", (Object) "num mark big file should not zip encrypt");
                return;
            } else {
                sb.c("UpdateMgr", (Object) "normal num mark big file");
            }
            if (!f0Var.f) {
                ea.c(f0Var.c);
            } else {
                ea.c(f0Var.g);
            }
            YellowPages instance = YellowPages.getInstance();
            if (instance != null && instance.update(str) != 0) {
                ((ra) ManagerCreatorC.getManager(ra.class)).d();
            }
        }
    }

    public void a(long j, ICheckListener iCheckListener) {
        String str;
        StringBuilder sb;
        int i;
        sb.a("UpdateMgr", (Object) ("check-checkFlag:[" + j + "]"));
        int i2 = 0;
        this.d.set(false);
        if (iCheckListener != null) {
            sb.a("UpdateMgr", (Object) "[callback]onCheckStarted");
            iCheckListener.onCheckStarted();
        }
        long prepareCheckFlag = UpdateConfig.prepareCheckFlag(j);
        ArrayList arrayList = new ArrayList();
        if (!f5.e().b()) {
            CheckResult checkResult = new CheckResult();
            checkResult.mTitle = "Warning";
            checkResult.mMessage = "Expired! Please contact TMS(Tencent Mobile Secure) group.";
            checkResult.mUpdateInfoList = arrayList;
            if (iCheckListener != null) {
                sb.a("UpdateMgr", (Object) "[callback]onCheckFinished--Licence Expired");
                iCheckListener.onCheckFinished(checkResult);
            }
        } else if (this.d.get()) {
            if (iCheckListener != null) {
                sb.a("UpdateMgr", (Object) "[callback]111onCheckCanceled");
                iCheckListener.onCheckCanceled();
            }
            a(0, iCheckListener);
        } else {
            ArrayList<c0> arrayList2 = new ArrayList<>();
            long[] jArr = UpdateConfig.UPDATE_FLAGS;
            int length = jArr.length;
            int i3 = 0;
            while (i3 < length) {
                long j2 = jArr[i3];
                if ((j2 & prepareCheckFlag) != 0) {
                    long j3 = UpdateConfig.UPDATA_FLAG_NUM_MARK;
                    if (j2 != UpdateConfig.UPDATA_FLAG_NUM_MARK) {
                        j3 = 2;
                        if (j2 != 2) {
                            j3 = UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large;
                            if (j2 != UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large) {
                                c0 b2 = b(j2);
                                if (b2 == null) {
                                    b2 = new c0();
                                    b2.f1028b = UpdateConfig.getFileIdByFlag(j2);
                                    b2.c = new byte[i2];
                                    b2.d = i2;
                                }
                                if (b2.c == null) {
                                    b2.c = ea.a("");
                                }
                                if (j2 == UpdateConfig.UPDATE_FLAG_VIRUS_BASE) {
                                    sb.a("UpdateMgr", (Object) "req::UpdateConfig.UPDATE_FLAG_VIRUS_BASE");
                                    sb = new StringBuilder();
                                    sb.append("req::fileId:[");
                                    sb.append(b2.f1028b);
                                    sb.append("]timestamp:[");
                                    i = b2.d;
                                } else if (j2 == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) {
                                    sb.a("UpdateMgr", (Object) "req::UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG");
                                    sb = new StringBuilder();
                                    sb.append("req::fileId:[");
                                    i = b2.f1028b;
                                } else {
                                    if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_RULE) {
                                        str = "rule";
                                    } else if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_MODEL) {
                                        str = OneTrack.Param.MODEL;
                                    } else if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_DIC) {
                                        str = "dic";
                                    } else if (j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGE_OFFLINE_DATABASE) {
                                        str = "yellow page offline database";
                                    } else {
                                        if (j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGE_OFFLINE_KEYWORDS) {
                                            str = "yellow page offline keywords";
                                        }
                                        arrayList2.add(b2);
                                    }
                                    sb.a("UpdateMgr", (Object) str);
                                    arrayList2.add(b2);
                                }
                                sb.append(i);
                                sb.append("]");
                                str = sb.toString();
                                sb.a("UpdateMgr", (Object) str);
                                arrayList2.add(b2);
                            }
                        }
                    }
                    arrayList2.addAll(a(j3));
                }
                i3++;
                i2 = 0;
            }
            a0 a0Var = new a0();
            a0Var.f1003b = arrayList2;
            a0Var.c = 1;
            e0 e0Var = new e0();
            long currentTimeMillis = System.currentTimeMillis();
            x5 f2 = b5.f();
            sb.a("UpdateMgr", (Object) ("[Shark]Cmd_CSConfInfo, sendShark, guid:[" + f2.b() + "]"));
            sb.a("UpdateMgr", "[UpdateManager] connect for  check update data");
            f2.a(108, a0Var, e0Var, 0, new C0040a(currentTimeMillis, iCheckListener, arrayList));
        }
    }

    public void a(UpdateInfo updateInfo) {
        IUpdateObserver iUpdateObserver;
        synchronized (this.e) {
            for (Map.Entry<Long, SoftReference<IUpdateObserver>> entry : this.e.entrySet()) {
                if (!((entry.getKey().longValue() & updateInfo.flag) == 0 || (iUpdateObserver = entry.getValue().get()) == null)) {
                    iUpdateObserver.onChanged(updateInfo);
                }
            }
        }
    }

    public void addObserver(long j, IUpdateObserver iUpdateObserver) {
        synchronized (this.e) {
            if (iUpdateObserver != null) {
                this.e.put(Long.valueOf(j), new SoftReference<>(iUpdateObserver));
            }
        }
    }

    public void cancel() {
        this.d.set(true);
    }

    public String getFileSavePath() {
        return this.c;
    }

    @Override // tmsdkobf.r4
    public int getSingletonType() {
        return 1;
    }

    @Override // tmsdkobf.r4
    public void onCreate(Context context) {
        this.f977b = context;
        this.c = context.getFilesDir().getAbsolutePath();
        this.f = b.b();
    }

    public void removeObserver(long j) {
        synchronized (this.e) {
            this.e.remove(Long.valueOf(j));
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:109:0x027e  */
    /* JADX WARNING: Removed duplicated region for block: B:110:0x028b  */
    /* JADX WARNING: Removed duplicated region for block: B:121:0x029b A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:123:0x02a4 A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x011c  */
    /* JADX WARNING: Removed duplicated region for block: B:86:0x0206  */
    /* JADX WARNING: Removed duplicated region for block: B:92:0x022e  */
    public boolean update(List<UpdateInfo> list, IUpdateListener iUpdateListener) {
        int i;
        long j;
        c0 c0Var;
        int b2;
        int a2;
        int i2;
        sb.a("UpdateMgr", (Object) ("update-updateInfoList:[" + list + "]updateListener:[" + iUpdateListener + "]"));
        this.d.set(false);
        if (iUpdateListener != null) {
            sb.a("UpdateMgr", (Object) "[callback]onUpdateStarted");
            iUpdateListener.onUpdateStarted();
        }
        if (!f5.e().b()) {
            if (iUpdateListener != null) {
                sb.a("UpdateMgr", (Object) "[callback]00onUpdateFinished");
                iUpdateListener.onUpdateFinished();
            }
            return false;
        } else if (this.d.get()) {
            if (iUpdateListener != null) {
                sb.a("UpdateMgr", (Object) "[callback]onUpdateCanceled");
                iUpdateListener.onUpdateCanceled();
                sb.a("UpdateMgr", (Object) "[callback]11onUpdateFinished");
                iUpdateListener.onUpdateFinished();
            }
            return false;
        } else {
            AtomicBoolean atomicBoolean = new AtomicBoolean(false);
            sb.a("UpdateMgr", (Object) ("updateInfoList size: " + list.size()));
            sb.c("UpdateMgr", "[net][https://mmgr.gtimg.com/qqsecure_config_update/qqsecure_config_update][UpdateManager] connect for update");
            int i3 = 1;
            int i4 = 0;
            boolean z = true;
            while (true) {
                if (i4 >= list.size()) {
                    break;
                }
                atomicBoolean.set(false);
                UpdateInfo updateInfo = list.get(i4);
                if (updateInfo == null) {
                    i = i3;
                } else {
                    sb.a("UpdateMgr", (Object) ("[" + i4 + "]updateInfo fileName:[" + updateInfo.fileName + "]url:[" + updateInfo.url + "]"));
                    if (list.size() == i3) {
                        if (iUpdateListener != null) {
                            sb.a("UpdateMgr", (Object) ("[callback]onProgressChanged:[" + i4 + "]"));
                            i2 = 50;
                        }
                        j = updateInfo.flag;
                        int i5 = 40458;
                        if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE || j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) {
                            b2 = b(1);
                            updateInfo.downType = 2;
                            if (b2 != 0) {
                                atomicBoolean.set(true);
                                updateInfo.errorCode = b2;
                                if (iUpdateListener != null) {
                                    sb.a("UpdateMgr", (Object) ("[callback]onUpdateEvent:[" + b2 + "]"));
                                    iUpdateListener.onUpdateEvent(updateInfo, b2);
                                }
                            }
                            if (!atomicBoolean.get()) {
                                a(updateInfo);
                                i = 1;
                                updateInfo.success = 1;
                                int largeMarkFileId = UpdateConfig.getLargeMarkFileId();
                                int i6 = updateInfo.mFileID;
                                if (largeMarkFileId == i6) {
                                    i5 = UpdateConfig.getLargeMarkFileId();
                                } else if (40458 != i6) {
                                    i5 = 40800;
                                    if (40800 != i6) {
                                        int i7 = 40461;
                                        if (40461 != i6) {
                                            i7 = 40801;
                                            if (40801 != i6) {
                                                c0Var = 50001 == i6 ? cc.a(50001, cc.a(this.f977b, 50001, ".sdb")) : b(updateInfo.flag);
                                                if (c0Var != null) {
                                                    updateInfo.checkSum = ea.a(c0Var.c);
                                                    updateInfo.timestamp = c0Var.d;
                                                }
                                            }
                                        }
                                        c0Var = cc.c(i7, cc.a(this.f977b, i7, ".sdb"));
                                        if (c0Var != null) {
                                        }
                                    }
                                }
                                c0Var = a(i5);
                                if (c0Var != null) {
                                }
                            } else {
                                i = 1;
                                updateInfo.success = 0;
                            }
                            this.f.a(updateInfo);
                            if (this.d.get()) {
                                if (iUpdateListener != null) {
                                    sb.a("UpdateMgr", (Object) "[callback]onUpdateCanceled");
                                    iUpdateListener.onUpdateCanceled();
                                }
                            }
                        } else {
                            if (!(j == 2147483648L || updateInfo == null || updateInfo.url == null)) {
                                ja jaVar = new ja(this.f977b);
                                jaVar.b(this.c + "/");
                                jaVar.a(updateInfo.fileName);
                                jaVar.a(new b(this, iUpdateListener, updateInfo, atomicBoolean));
                                long j2 = updateInfo.flag;
                                String str = null;
                                ja.a cVar = j2 == UpdateConfig.UPDATA_FLAG_NUM_MARK ? new c(updateInfo) : j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large ? new d(updateInfo) : null;
                                sb.a("UpdateMgr", (Object) "before invoke httpGetFile.doGetFile()");
                                while (true) {
                                    a2 = jaVar.a(str, updateInfo.url, false, cVar);
                                    if (a2 != -7) {
                                        break;
                                    }
                                    str = null;
                                }
                                if (!atomicBoolean.get() && updateInfo.flag == 2 && a2 == 0) {
                                    b(updateInfo);
                                }
                                if (!atomicBoolean.get() && 40458 == updateInfo.mFileID && a2 == 0) {
                                    d(updateInfo);
                                }
                                if (!atomicBoolean.get() && UpdateConfig.getLargeMarkFileId() == updateInfo.mFileID && a2 == 0) {
                                    c(updateInfo);
                                }
                                if (!atomicBoolean.get() && 40800 == updateInfo.mFileID && a2 == 0) {
                                    d(updateInfo);
                                }
                                if (!atomicBoolean.get() && 40461 == updateInfo.mFileID && a2 == 0) {
                                    e(updateInfo);
                                }
                                if (!atomicBoolean.get() && 40801 == updateInfo.mFileID && a2 == 0) {
                                    e(updateInfo);
                                }
                                if (a2 != 0) {
                                    updateInfo.errorCode = a2;
                                }
                            }
                            if (!atomicBoolean.get()) {
                            }
                            this.f.a(updateInfo);
                            if (this.d.get()) {
                            }
                        }
                        z = false;
                        if (!atomicBoolean.get()) {
                        }
                        this.f.a(updateInfo);
                        if (this.d.get()) {
                        }
                    } else {
                        if (iUpdateListener != null) {
                            sb.a("UpdateMgr", (Object) ("[callback]onProgressChanged:[" + i4 + "]"));
                            i2 = (i4 * 100) / list.size();
                        }
                        j = updateInfo.flag;
                        int i52 = 40458;
                        if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE) {
                        }
                        b2 = b(1);
                        updateInfo.downType = 2;
                        if (b2 != 0) {
                        }
                        if (!atomicBoolean.get()) {
                        }
                        this.f.a(updateInfo);
                        if (this.d.get()) {
                        }
                    }
                    iUpdateListener.onProgressChanged(updateInfo, i2);
                    j = updateInfo.flag;
                    int i522 = 40458;
                    if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE) {
                    }
                    b2 = b(1);
                    updateInfo.downType = 2;
                    if (b2 != 0) {
                    }
                    if (!atomicBoolean.get()) {
                    }
                    this.f.a(updateInfo);
                    if (this.d.get()) {
                    }
                }
                i4++;
                i3 = i;
            }
            if (iUpdateListener != null) {
                sb.a("UpdateMgr", (Object) "[callback]onUpdateFinished");
                iUpdateListener.onUpdateFinished();
                this.f.a();
            }
            sb.c("UpdateMgr", "[net][https://mmgr.gtimg.com/qqsecure_config_update/qqsecure_config_update][UpdateManager] disconnect for update");
            return z;
        }
    }
}